<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>员工表格练习</title>
</head>
<body>
    姓名:<input type="text" placeholder="请输入员工姓名" id="i1">
    工资:<input type="text" placeholder="请输入员工工资" id="i2">
    岗位:<input type="text" placeholder="请输入员工岗位" id="i3">
    <button onclick="add()">添加</button>
    <hr>
    <table border="1">
        <caption>员工表</caption>
        <tr>
            <th>姓名</th>
            <th>工资</th>
            <th>岗位</th>
        </tr>
    </table>
    <script>
        let table = document.querySelector("table");
        console.log(table);
        function add() {
            let value1 = document.getElementById("i1").value;
            let value2 = document.getElementById("i2").value;
            let value3 = document.getElementById("i3").value;

            let newRow = table.insertRow();
            let cell0 = newRow.insertCell(0);
            let cell1 = newRow.insertCell(1);
            let cell2 = newRow.insertCell(2);

            cell0.textContent=value1;
            cell1.textContent=value2;
            cell2.textContent=value3;
        }
    </script>
</body>
</html>